/*** Eclipse Class Decompiler plugin, copyright (c) 2016 Chen Chao (cnfree2000@hotmail.com) ***/
package nc.ui.pubapp.uif2app.components.grand;

import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Graphics;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import nc.desktop.ui.WorkbenchEnvironment;
import nc.ui.pub.beans.UIPanel;
import nc.ui.pub.beans.UITable;
import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pub.bill.BillData;
import nc.ui.pub.bill.BillEditEvent;
import nc.ui.pub.bill.BillModel;
import nc.ui.pubapp.uif2app.components.grand.action.ExpendShrinkGrandCardAction;
import nc.ui.pubapp.uif2app.components.grand.model.DefaultGrandValidationService;
import nc.ui.pubapp.uif2app.components.grand.model.IGrandValidationService;
import nc.ui.pubapp.uif2app.components.grand.model.MainGrandAppEvent;
import nc.ui.pubapp.uif2app.components.grand.model.MainGrandEventTypeEnum;
import nc.ui.pubapp.uif2app.components.grand.model.MainGrandModel;
import nc.ui.pubapp.uif2app.components.grand.model.MainGrandStatusTypeEnum;
import nc.ui.pubapp.uif2app.components.grand.util.CardPanelEventUtil;
import nc.ui.pubapp.uif2app.components.grand.util.MainGrandAssist;
import nc.ui.pubapp.uif2app.components.grand.valueStrategy.AbstractGrandComponentValueAdapter;
import nc.ui.pubapp.uif2app.components.grand.valueStrategy.MainGrandNotDelValueAdapter;
import nc.ui.pubapp.uif2app.event.OrgChangedEvent;
import nc.ui.pubapp.uif2app.event.card.BodyRowEditType;
import nc.ui.pubapp.uif2app.event.card.CardBodyBeforeTabChangeEvent;
import nc.ui.pubapp.uif2app.event.card.CardBodyRowChangedEvent;
import nc.ui.pubapp.uif2app.event.card.CardBodyRowEditEvent;
import nc.ui.pubapp.uif2app.event.card.CardBodyTabChangedEvent;
import nc.ui.pubapp.uif2app.event.list.ListHeadDoubleClickEvent;
import nc.ui.pubapp.uif2app.event.list.ListHeadRowChangedEvent;
import nc.ui.pubapp.uif2app.view.BillForm;
import nc.ui.uif2.AppEvent;
import nc.ui.uif2.UIState;
import nc.ui.uif2.components.AutoShowUpEventSource;
import nc.ui.uif2.components.IAutoShowUpEventListener;
import nc.ui.uif2.editor.BillListView;
import nc.ui.uif2.editor.value.IComponentValueStrategy;
import nc.ui.uif2.model.AbstractAppModel;
import nc.ui.uif2.model.BillManageModel;
import nc.vo.pub.AggregatedValueObject;
import nc.vo.pub.BusinessException;
import nc.vo.pub.CircularlyAccessibleValueObject;
import nc.vo.pub.SuperVO;
import nc.vo.sm.UserVO;
import nc.vo.uap.rbac.FuncSubInfo;
import nc.vo.uif2.AppStatusRegistery;
import nc.vo.uif2.AppStatusRegisteryCallback;
import nc.vo.uif2.LoginContext;

public class CardGrandPanelComposite extends GrandPanelComposite {
	private static final long serialVersionUID = 3909667539006135048L;
	private ExpendShrinkGrandCardAction expendShrinkGrandCardAction;
	private JSplitPane headpanelcombo;
	protected CardGrandPanel expendPane;
	public JPanel switchGrandCardPanel;
	private boolean grandAutoAddLine;
	private IGrandValidationService grandValidationService;
	private MainGrandBlankFilter mainGrandBlankFilter;
	private AutoShowUpEventSource autoShowUpComponent;
	protected IComponentValueStrategy componentValueManager;

	public CardGrandPanelComposite() {
		this.expendShrinkGrandCardAction = null;

		this.grandAutoAddLine = false;

		this.grandValidationService = new DefaultGrandValidationService();

		this.autoShowUpComponent = new AutoShowUpEventSource(this);
	}

	public void setAutoShowUpEventListener(IAutoShowUpEventListener l) {
		this.autoShowUpComponent.setAutoShowUpEventListener(l);
	}

	public void showMeUp() {
		getModel().mainCardGrandInit();

		this.autoShowUpComponent.showMeUp();

		showGranListUp();
	}

	private void showGranListUp() {
		int currentRow = ((BillForm) this.mainPanel).getBillCardPanel()
				.getBillTable().getSelectedRow();

		if (currentRow < 0) {
			currentRow = CardPanelEventUtil.setBodyRowSelectionInterval(this);
		}

		CardBodyRowChangedEvent event = new CardBodyRowChangedEvent(
				((BillForm) this.mainPanel).getBillCardPanel(),
				new BillEditEvent(this, currentRow, currentRow));

		getModel().getMainModel().fireEvent(event);
	}

	public void initUI() {
		readCardCacheInfo();

		super.initUI();

		initCardListener();

		getMainGrandAssist().setMainGrandModel(getModel());

		registeCallbak();

		getMainGrandAssist().constructPreColumBillItem(
				(BillForm) getMainPanel());
		getModel().setMaingrandrelationship(getMaingrandrelationship());
	}

	public void readCardCacheInfo() {
		int lastsize = getLastSize().intValue();
		if ((lastsize == 0) || (lastsize < 0)) {
			getModel().setMainGrandCardEnumState(
					MainGrandStatusTypeEnum.card_main_show_grand_hide);
			getListCardSplitPane().setEnabled(false);
		} else {
			getModel().setMainGrandCardEnumState(
					MainGrandStatusTypeEnum.card_main_show_grand_show);
			getListCardSplitPane().setDividerLocation(lastsize);
			if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_hide) {
				getListCardSplitPane().setEnabled(false);
			} else
				getListCardSplitPane().setEnabled(true);
		}
	}

	public boolean setGrandPanelMax() {
		boolean ret = false;
		if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_max) {
			getListCardSplitPane().setResizeWeight(0.0D);
			float currentLocation = getListCardSplitPane().getDividerLocation();
			float mainPanelSize = getHeight();
			setCurrentLocation(currentLocation / mainPanelSize);
			getListCardSplitPane().setDividerLocation(0);
			getListCardSplitPane().resetToPreferredSizes();
			ret = true;
		}
		return ret;
	}

	public Integer getLastSize() {
		int d = 0;

		BillManageModel mainmodel = (BillManageModel) ((BillForm) getMainPanel())
				.getModel();

		Object statusObj = mainmodel.getContext().getStatusRegistery()
				.getAppStatusObject(getGrandCacheId());
		if ((statusObj == null) || (!(statusObj instanceof HashMap))) {
			return Integer.valueOf(0);
		}
		d = ((Integer) ((HashMap) statusObj).get("Size")).intValue();
		return Integer.valueOf(d);
	}

	public Component getGrandPanel() {
		if ((this.expendPane != null)
				&& (this.expendPane.getGrandComoPanel() != null)
				&& (this.expendPane.getGrandComoPanel().getRightComponent() != null)) {
			if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_show) {
				this.expendPane.getGrandComoPanel().getRightComponent()
						.setVisible(true);
			} else {
				this.expendPane.getGrandComoPanel().getRightComponent()
						.setVisible(false);
			}
			return this.expendPane;
		}

		readCardGrandConfigXML();

		if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_hide) {
			this.expendPane.getGrandComoPanel().getRightComponent()
					.setVisible(false);

			cardPanelBeforeResize();
		} else {
			this.expendPane.getGrandComoPanel().getRightComponent()
					.setVisible(true);
		}

		return this.expendPane;
	}

	public void readCardGrandConfigXML() {
		Map panelmap = getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite();
		Iterator keys = panelmap.keySet().iterator();
		this.switchGrandCardPanel = new UIPanel();
		this.switchGrandCardPanel.setLayout(new CardLayout());

		this.expendPane = new CardGrandPanel();
		this.expendPane.setGrandlabel(new JLabel(getGrandString()));
		this.expendPane.setExpendShrinkAction(this.expendShrinkGrandCardAction);

		getModel().addAppEventListener(this.expendPane);

		getModel().mainCardGrandInit();

		JSplitPane splitane = this.expendPane.getGrandComoPanel();
		splitane.setEnabled(false);
		if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_show) {
			splitane.setBottomComponent(this.switchGrandCardPanel);
			splitane.getBottomComponent().setVisible(true);
		} else {
			splitane.setBottomComponent(this.switchGrandCardPanel);
		}

		while (keys.hasNext()) {
			String uniquekey = (String) keys.next();
			Object component = panelmap.get(uniquekey);
			Object addcomponent = null;
			if (component instanceof BillListView) {
				addcomponent = ((BillListView) component).getBillListPanel();
			} else if (component instanceof BillForm) {
				addcomponent = ((BillForm) component).getBillCardPanel();

				((BillForm) component).getBillCardPanel()
						.addTabbedPaneTabChangeListener(getMediator(), 1);
				((BillForm) component).getBillCardPanel()
						.addTabbedPaneTabChangeListener2(getMediator(), 1);
			}

			this.switchGrandCardPanel.add((Component) addcomponent, uniquekey);
		}
	}

	public void paint(Graphics g) {
		super.paint(g);

		String currentBodyTab = ((BillForm) getMainPanel()).getBillCardPanel()
				.getCurrentBodyTableCode();
		Component grandComposite = (Component) getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite().get(currentBodyTab);

		if (isNeedToPaint()) {
			return;
		}
		if ((getGrandPanel() != null) && (grandComposite != null)
				&& (isNeedToRepaint())) {
			paintGrandList();
			setNeedToRepaint(false);
		}
	}

	private void paintGrandList() {
		if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_hide) {
			setGrandHideStatus(false);
		} else {
			if (getModel().getCardGrandEnumState() != MainGrandStatusTypeEnum.card_grand_show)
				return;
			if (getCurrentLocation() > 0.9D) {
				getListCardSplitPane().setDividerLocation(0.7D);
			} else
				getListCardSplitPane().setDividerLocation(getCurrentLocation());
		}
	}

	private boolean isNeedToPaint() {
		boolean flag = false;

		if ((getModel().getCardHeadStateEnum() == MainGrandStatusTypeEnum.card_head_max)
				|| (getModel().getCardBodyEnumState() == MainGrandStatusTypeEnum.card_body_max)
				|| (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_max)) {
			flag = true;
		}

		return flag;
	}

	protected void registeCallbak() {
		BillManageModel mainmodel = (BillManageModel) ((BillForm) getMainPanel())
				.getModel();
		if ((mainmodel.getContext() == null)
				|| (mainmodel.getContext().getStatusRegistery() == null)) {
			return;
		}
		mainmodel.getContext().getStatusRegistery()
				.addCallback(new AppStatusRegisteryCallback() {
					public Object getID() {
						return CardGrandPanelComposite.this.getGrandCacheId();
					}

					public Object getStatusObject() {
						Map cardmap = new HashMap();
						cardmap.put("Size", Integer
								.valueOf(CardGrandPanelComposite.this
										.getListCardSplitPane()
										.getDividerLocation()));
						return cardmap;
					}
				});
	}

	private String getGrandCacheId() {
		String userId = WorkbenchEnvironment.getInstance().getLoginUser()
				.getCuserid();
		String funCode = getModel().getMainModel().getContext().getFuncInfo()
				.getFuncode();
		return userId + funCode + "CardGrand_Size";
	}

	public void handleEvent(AppEvent event) {
		UIState mainState = ((BillForm) getMainPanel()).getModel().getUiState();

		if (event instanceof MainGrandAppEvent) {
			mainGrandProcess(event);
		} else if (event instanceof CardBodyRowChangedEvent) {
			onRowChangeHandler(mainState, (CardBodyRowChangedEvent) event,
					this.grandValidationService);
			//CardPanelEventUtil.grandMMQuery(this);
		} else if (event instanceof CardBodyTabChangedEvent) {
			onBodyTabChange(mainState, event);
		} else if (event instanceof CardBodyBeforeTabChangeEvent) {
			onBeforeBodyTabChange(mainState);
		} else if (event instanceof CardBodyRowEditEvent) {
			onRowEditHandler(event, mainState);
		} else if (event instanceof ListHeadRowChangedEvent) {
			onHeadRowChange(mainState);
		} else if (event instanceof ListHeadDoubleClickEvent) {
			onHeadDoubleClick(mainState);
		} else if (event.getType().equals("UiState_Changed")) {
			onUiStateChange(mainState);
		} else if (OrgChangedEvent.class.getName().equals(event.getType())) {
			CardPanelEventUtil.orgChangeProcess(this);
		} else {
			if ((!(event.getType().equals("Selection_Changed")))
					|| (!(isShowing())))
				return;
			CardPanelEventUtil.grandModelInit(this);
		}
	}

	private void mainGrandProcess(AppEvent event) {
		if (event.getType().equals(
				MainGrandEventTypeEnum.grandcard_expend.toString())) {
			displayGrandPanel();
			((BillForm) this.mainPanel).getBillCardPanel().getHeadUIPanel()
					.setVisible(false);
			((HeadPanelCombo) this.headpanelcombo).excludeButtonAction();
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.grandcard_shrink.toString())) {
			setGrandPanelMin();
			((BillForm) this.mainPanel).getBillCardPanel().getHeadUIPanel()
					.setVisible(true);
			((HeadPanelCombo) this.headpanelcombo).expendButtonAction();
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.grandcard_max.toString())) {
			setGrandPanelMax();
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.grandcard_min.toString())) {
			resizeGrandPanel();
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.bodycard_max.toString())) {
			((BillForm) getMainPanel()).getBillCardPanel().setPosMaximized(1);
			((CardGrandPanel) getGrandPanel()).getGrandComoPanel().setVisible(
					false);
			hideGrandPanel();
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.bodycard_min.toString())) {
			((BillForm) getMainPanel()).getBillCardPanel().setPosMaximized(-1);
			if (getModel().isHandleListCardIsShow()) {
				((CardGrandPanel) getGrandPanel()).getGrandComoPanel()
						.setVisible(true);
				resizeGrandPanel();
			}
		} else if (event.getType().equals(
				MainGrandEventTypeEnum.headcard_max.toString())) {
			((BillForm) getMainPanel()).getBillCardPanel().getHeadUIPanel()
					.setVisible(true);
			((BillForm) getMainPanel()).getBillCardPanel().setPosMaximized(0);
			((CardGrandPanel) getGrandPanel()).getGrandComoPanel().setVisible(
					false);
			hideGrandPanel();
		}

		if (event.getType().equals(
				MainGrandEventTypeEnum.bomMMQuery.toString())){
			CardPanelEventUtil.grandMMQuery(this);
		}
		
		if (event.getType().equals(
				MainGrandEventTypeEnum.headcard_min.toString())) {
			((BillForm) getMainPanel()).getBillCardPanel().setPosMaximized(-1);
			if (getModel().isHandleListCardIsShow()) {
				((CardGrandPanel) getGrandPanel()).getGrandComoPanel()
						.setVisible(true);
				resizeGrandPanel();
			}
		} else {
			if (!(event.getType()
					.equals(MainGrandEventTypeEnum.loadcardgranddata.toString())))
				return;
			CardPanelEventUtil.grandModelInit(this);
		}
		
	}

	private void onBodyTabChange(UIState state, AppEvent event) {
		if (getModel().getCardBodyEnumState() != MainGrandStatusTypeEnum.card_body_max) {
			getMainGrandAssist().updateGrandCardByBodyTab(this);
		} else if (getModel().getCardBodyEnumState() == MainGrandStatusTypeEnum.card_body_max) {
			if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_hide) {
				float panelHeight = getListCardSplitPane().getHeight() - 25;
				setUiDividerLocation(panelHeight
						/ getListCardSplitPane().getHeight());
			} else if (getModel().getCardGrandEnumState() == MainGrandStatusTypeEnum.card_grand_show) {
				setUiDividerLocation(getCurrentLocation());
			}
		}
		if (state.equals(UIState.NOT_EDIT)) {
			int currentRow = ((BillForm) this.mainPanel).getBillCardPanel()
					.getBillTable().getSelectedRow();
			if (currentRow >= 0)
				return;
			String currentbodyTabCode = ((BillForm) this.mainPanel)
					.getBillCardPanel().getCurrentBodyTableCode();

			BillForm grandBillForm = (BillForm) getMaingrandrelationship()
					.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

			if (grandBillForm != null) {
				String grandTabCode = grandBillForm.getBillCardPanel()
						.getCurrentBodyTableCode();
				grandBillForm.getBillCardPanel().getBillData()
						.setBodyValueVO(grandTabCode, null);
			}
		}
	}

	private void onBeforeBodyTabChange(UIState state) {
		int currentRow = ((BillForm) this.mainPanel).getBillCardPanel()
				.getBillTable().getSelectedRow();
		if (currentRow >= 0)
			if (state.equals(UIState.EDIT)) {
				getMainGrandAssist().showMainCardDataByGrandTabEdit(
						(BillForm) this.mainPanel, currentRow,
						getMaingrandrelationship());
			} else if (state.equals(UIState.ADD))
				getMainGrandAssist().showMainCardDataByGrandTab(
						(BillForm) this.mainPanel, currentRow,
						getMaingrandrelationship());
	}

	private void onHeadRowChange(UIState state) {
		String currentbodyTabCode = ((BillForm) this.mainPanel)
				.getBillCardPanel().getCurrentBodyTableCode();
		BillForm grandBillForm = (BillForm) getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

		if (grandBillForm != null) {
			String[] tabCodes = grandBillForm.getBillCardPanel().getBillData()
					.getBodyTableCodes();
			for (String grandTabCode : tabCodes)
				grandBillForm.getBillCardPanel().getBillModel(grandTabCode)
						.clearBodyData();
		}
	}

	private void onHeadDoubleClick(UIState state) {
		String currentbodyTabCode = ((BillForm) this.mainPanel)
				.getBillCardPanel().getCurrentBodyTableCode();
		BillForm grandBillForm = (BillForm) getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

		if (grandBillForm != null) {
			String grandTabCode = grandBillForm.getBillCardPanel()
					.getCurrentBodyTableCode();

			List queryList = getMainGrandAssist().setGrand2CurrentPanel(this);
			if ((queryList != null) && (queryList.size() > 0)) {
				grandBillForm
						.getBillCardPanel()
						.getBillData()
						.setBodyValueVO(
								grandTabCode,
								(CircularlyAccessibleValueObject[]) queryList
										.toArray(new SuperVO[0]));

				CardPanelEventUtil.execlFormula(grandBillForm, grandTabCode);
			} else {
				grandBillForm.getBillCardPanel().getBillModel(grandTabCode)
						.clearBodyData();
			}
		}
	}

	private void onUiStateChange(UIState state) {
		String currentbodyTabCode = ((BillForm) getMainPanel())
				.getBillCardPanel().getCurrentBodyTableCode();
		BillForm grandBillForm = (BillForm) getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

		if (state.equals(UIState.ADD)) {
			getModel().clearBufferData();
			getMainGrandAssist().setGrandStatusByMainForm(this);
			if (grandBillForm != null) {
				grandBillForm.getBillCardPanel().getBillData().clearViewData();
			}
		} else if (state.equals(UIState.EDIT)) {
			getModel().setAddReturnList(false);

			getModel().clearBufferData();
			getMainGrandAssist().setGrandStatusByMainForm(this);
			if (grandBillForm != null) {
				grandBillForm.getBillCardPanel().getBillData().clearViewData();
			}
		} else if (state.equals(UIState.NOT_EDIT)) {
			getMainGrandAssist().setGrandStatusByMainForm(this);
		}
	}

	private void onRowEditHandler(AppEvent event, UIState state) {
		if (((CardBodyRowEditEvent) event).getRowEditType() == BodyRowEditType.DELLINE) {
			String currentbodyTabCode = ((BillForm) this.mainPanel)
					.getBillCardPanel().getCurrentBodyTableCode();

			BillForm grandBillForm = (BillForm) getMaingrandrelationship()
					.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

			if (grandBillForm != null) {
				int deletine = ((CardBodyRowEditEvent) event)
						.getBillCardPanel().getBillTable().getSelectedRow();
				if (!(getModel().isFlag())) {
					if (state.equals(UIState.ADD)) {
						getMainGrandAssist().delGrandCardDataByMainRowAdd(
								(BillForm) this.mainPanel, deletine,
								grandBillForm);
					} else if (state.equals(UIState.EDIT)) {
						getMainGrandAssist().delGrandCardDataByMainRowEdit(
								(BillForm) this.mainPanel, deletine,
								grandBillForm);
					}

				} else
					getModel().setFlag(false);
			}
		}
	}

	private void onRowChangeHandler(UIState state,
			CardBodyRowChangedEvent event,
			IGrandValidationService grandValidationService) {
		if (state.equals(UIState.EDIT)) {
			CardPanelEventUtil.rowChangeStateIsEdit(this, event,
					grandValidationService, this.mainGrandBlankFilter);
		} else if (state.equals(UIState.ADD)) {
			CardPanelEventUtil.rowChangeStateIsAdd(this, event,
					grandValidationService, this.mainGrandBlankFilter);
		} else {
			if (!(state.equals(UIState.NOT_EDIT)))
				return;
			CardPanelEventUtil.rowChangeStateIsnoEdit(this, event);
		}
	}

	public Object getValue() {
		int currentRow = ((BillForm) this.mainPanel).getBillCardPanel()
				.getBillTable().getSelectedRow();

		((BillForm) this.mainPanel).getBillCardPanel().stopEditing();
		String currentbodyTabCode = ((BillForm) this.mainPanel)
				.getBillCardPanel().getCurrentBodyTableCode();
		((BillForm) this.mainPanel).getBillCardPanel().getBillData()
				.getBillstatus();
		Object grandObjBillForm = getMaingrandrelationship()
				.getBodyTabTOGrandCardComposite().get(currentbodyTabCode);

		if (grandObjBillForm != null) {
			BillForm grandBillForm = (BillForm) grandObjBillForm;
			grandBillForm.getBillCardPanel().stopEditing();
			CardBodyRowChangedEvent event = new CardBodyRowChangedEvent(
					((BillForm) this.mainPanel).getBillCardPanel(),
					new BillEditEvent(this, currentRow, currentRow));

			getModel().getMainModel().fireEvent(event);
		}

		AggregatedValueObject aggVo = (AggregatedValueObject) getComponentValueManager()
				.getValue();
		return aggVo;
	}

	public void setValue(Object object) throws BusinessException {
		getComponentValueManager().setValue(object);
	}

	public boolean isDisplyGrandPanel() {
		return false;
	}

	protected void initCardListener() {
		((BillForm) this.mainPanel).getModel().addAppEventListener(this);
	}

	public MainGrandBlankFilter getMainGrandBlankFilter() {
		return this.mainGrandBlankFilter;
	}

	public void setMainGrandBlankFilter(
			MainGrandBlankFilter mainGrandBlankFilter) {
		this.mainGrandBlankFilter = mainGrandBlankFilter;
	}

	public JSplitPane getHeadpanelcombo() {
		return this.headpanelcombo;
	}

	public void setHeadpanelcombo(JSplitPane headpanelcombo) {
		this.headpanelcombo = headpanelcombo;
	}

	public ExpendShrinkGrandCardAction getExpendShrinkGrandCardAction() {
		return this.expendShrinkGrandCardAction;
	}

	public void setExpendShrinkGrandCardAction(
			ExpendShrinkGrandCardAction expendShrinkGrandCardAction) {
		this.expendShrinkGrandCardAction = expendShrinkGrandCardAction;
	}

	public IGrandValidationService getGrandValidationService() {
		return this.grandValidationService;
	}

	public void setGrandValidationService(
			IGrandValidationService grandValidationService) {
		this.grandValidationService = grandValidationService;
	}

	public boolean isGrandAutoAddLine() {
		return this.grandAutoAddLine;
	}

	public void setGrandAutoAddLine(boolean grandAutoAddLine) {
		if (this.grandAutoAddLine == grandAutoAddLine) {
			return;
		}
		this.grandAutoAddLine = grandAutoAddLine;
	}

	public IComponentValueStrategy getComponentValueManager() {
		if (this.componentValueManager == null) {
			this.componentValueManager = new MainGrandNotDelValueAdapter();
		}
		if (this.componentValueManager instanceof AbstractGrandComponentValueAdapter) {
			((AbstractGrandComponentValueAdapter) this.componentValueManager)
					.setMainGrandPanel(this);
			((AbstractGrandComponentValueAdapter) this.componentValueManager)
					.setMainGrandBlankFilter(getMainGrandBlankFilter());

			((AbstractGrandComponentValueAdapter) this.componentValueManager)
					.setMainGrandRelationShip(getMaingrandrelationship());
		}

		return this.componentValueManager;
	}

	public void setComponentValueManager(
			IComponentValueStrategy componentValueManager) {
		this.componentValueManager = componentValueManager;
	}
}